<?php
namespace app\admin\model;

use think\Model;

class AddAnotherMoneyInfo extends Model
{

    /**
     * 获取平台提取手续费列表
     * @param $start_time 开始时间
     * @param $end_time 结束时间
     * @author hey_heyang
     * @return  array()
     */
    public function getAnotherList($start_time,$end_time,$page_size=10,$sort='desc',$type=false){
        if($start_time && $end_time){
            $time1 = strtotime($start_time);
            $time2 = strtotime($end_time.'+ 1 day');
            $condition['payment_time'] = array('between',$time1.','.$time2);
        }elseif($start_time){
            $condition['payment_time'] = array('eqt',strtotime($start_time));
        }elseif($end_time){
            $condition['payment_time'] = array('elt',strtotime($end_time.'+ 1 day')-1);
        }
        $condition['type']=2;
        $field = 'FROM_UNIXTIME(payment_time) as time,"公司" as username," "as mobile,money,"提现到银行卡" as "type"';
        if($type){
            $data=$this->where($condition)->field($field)->order('time '.$sort)->select()->toArray();
        }else{
            $data=$this->where($condition)->field($field)->order('time '.$sort)->paginate($page_size,false,page_param());
        }

        return $data;
    }


    /**
     * 获取平台充值列表
     * @param $start_time 开始时间
     * @param $end_time 结束时间
     * @author hey_heyang
     * @return  array()
     */
    public function getAnotherChargeList($start_time,$end_time,$page_size,$sort='desc',$type=false){
        if($start_time && $end_time){
            $time1 = strtotime($start_time);
            $time2 = strtotime($end_time.'+ 1 day');
            $condition['payment_time'] = array('between',$time1.','.$time2);
        }elseif($start_time){
            $condition['payment_time'] = array('eqt',strtotime($start_time));
        }elseif($end_time){
            $condition['payment_time'] = array('elt',strtotime($end_time.'+ 1 day')-1);
        }
        $condition['type']=3;
        $field = 'FROM_UNIXTIME(payment_time) as time,"公司" as username," "as mobile,money,"充值" as "type"';
        if($type){
            $data=$this->where($condition)->field($field)->select()->toArray();
        }else{
            $data=$this->where($condition)->field($field)->order('time '.$sort)->paginate($page_size,false,page_param());
        }

        return $data;
    }


    /**
     * 获取平台推广结算列表
     * @param $start_time 开始时间
     * @param $end_time 结束时间
     * @author hey_heyang
     * @return  array()
     */
    public function getAnotherJsList($start_time,$end_time,$page_size,$sort='desc',$type=false){
        if($start_time && $end_time){
            $time1 = strtotime($start_time);
            $time2 = strtotime($end_time.'+ 1 day');
            $condition['payment_time'] = array('between',$time1.','.$time2);
        }elseif($start_time){
            $condition['payment_time'] = array('eqt',strtotime($start_time));
        }elseif($end_time){
            $condition['payment_time'] = array('elt',strtotime($end_time.'+ 1 day')-1);
        }
        $condition['type']=4;
        $field = 'FROM_UNIXTIME(payment_time) as time,"公司" as username," "as mobile,money,"结算" as "type"';
        if($type){
            $data=$this->where($condition)->field($field)->select()->toArray();
        }else{
            $data=$this->where($condition)->field($field)->order('time '.$sort)->paginate($page_size,false,page_param());
        }

        return $data;
    }


}